<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="/WEB-INF/tlds/c.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/tlds/fmt.tld" prefix="fmt"%>
<%@ taglib uri="/WEB-INF/tlds/tiles-jsp.tld" prefix="tiles"%>
<c:set var="appCtx" value="${pageContext.request.contextPath}" />

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<tiles:insertAttribute name="common-resources" />

<script type="text/javascript">
$(function() {
	$("#buscarBtn").button();
	$("#buscarBtn").click(function() {
		$("#buscarForm").submit();
		return false;
	});
	
	$(".seleccionarbtn").button();
	$(".seleccionarbtn").click(function() {
		/* Se carga el id de la empresa buscada */	
		var idEmpresa =  $(this).parents("tr").first().attr("id");
		window.parent.$("#cuit").val(idEmpresa);
		
		/* Se cierra el dialog de busqueda */
		window.parent.$('#buscarEmpresaIframe').remove();
		return false;
	});

});	
</script>
</head>
<body>

	<form class="form" action="${appCtx}/buscarEmpresa" method="post" id="buscarForm">
	<table style="width:580px;margin-left:10px;">
	<tr><td>
	 		<fieldset>
				<legend class="form formTitle">
					&nbsp;<fmt:message key="message.searchCriteria" />
				</legend>
				<table>
					<tr>
						<td class="label"><label><fmt:message key="label.company.cuit" />:</label></td>
						<td><input type="text" name="cuit" style="width:250px;" /></td>
					</tr>
					<tr>
						<td class="label"><label><fmt:message key="label.company.corporateName" />:</label></td>
						<td><input name="razonSocial" type="text" style="width:250px;" /></td>
					</tr>
				</table>
			</fieldset>	
	</td></tr>
	<tr>
		<td align="right"><button id="buscarBtn"><fmt:message key="button.search" /></button></td>
	</tr>
	</table>
	</form>
	
	<div><br /></div>
	
	<c:if test="${displayList == 1}">
		<form class="form">
		<div id="resultados" style="margin-left:10px;">
			<div class="encabezadoDeResultado" style="width:570px;">
					<fmt:message key="message.searchResults" />
			</div>
			<table class="tablaDeResultado" style="width:580px;" border="0">
				<thead>
					<tr>
						<th>&nbsp;<fmt:message key="label.company.cuit" /></th>
						<th>&nbsp;<fmt:message key="label.company.corporateName" /></th>
						<th style="width:100px;">&nbsp;<fmt:message key="label.select" /></th>
					</tr>
				</thead>
				<tbody>
					<tr id="<c:out value='11'/>">
						<td>300306803065030</td>
						<td>CONDE SANTIAGO</td>
						<td><button class="seleccionarbtn"><fmt:message key="label.select" /></button></td>
					</tr>
					<tr id="<c:out value='22'/>">
						<td>300306803065030</td>
						<td>ASOCIACION PROPIETARIOS CONJUNTO URBANO</td>
						<td><button class="seleccionarbtn"><fmt:message key="label.select" /></button></td>
					</tr>
					<tr id="<c:out value='33'/>">
						<td>300306803065030</td>
						<td>CONDE SANTIAGO</td>
						<td><button class="seleccionarbtn"><fmt:message key="label.select" /></button></td>
					</tr>
					<tr id="<c:out value='44'/>">
						<td>300306803065030</td>
						<td>ASOCIACION PROPIETARIOS CONJUNTO URBANO</td>
						<td><button class="seleccionarbtn"><fmt:message key="label.select" /></button></td>
					</tr>
					<tr id="<c:out value='55'/>">
						<td>300306803065030</td>
						<td>CONDE SANTIAGO</td>
						<td><button class="seleccionarbtn"><fmt:message key="label.select" /></button></td>
					</tr>
					<tr id="<c:out value='66'/>">
						<td>300306803065030</td>
						<td>ASOCIACION PROPIETARIOS CONJUNTO URBANO</td>
						<td><button class="seleccionarbtn"><fmt:message key="label.select" /></button></td>
					</tr>
					<tr id="<c:out value='77'/>">
						<td>300306803065030</td>
						<td>CONDE SANTIAGO</td>
						<td><button class="seleccionarbtn"><fmt:message key="label.select" /></button></td>
					</tr>
					<tr id="<c:out value='88'/>">
						<td>300306803065030</td>
						<td>ASOCIACION PROPIETARIOS CONJUNTO URBANO</td>
						<td><button class="seleccionarbtn"><fmt:message key="label.select" /></button></td>
					</tr>
				</tbody>
			</table>
		</div>
		</form>
	</c:if>

</body>
</html>